package cn.hanna.springcloud.controller;

import cn.hanna.springcloud.service.PaymentHystrixService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author smileha
 * @create 2021-10-17 19:20
 * @description
 */
@RestController
public class PaymentHystrixController {

    @Autowired
    private PaymentHystrixService paymentHystrixService;

    @GetMapping("/payment/hystrix/ok/{id}")
    public String paymentInfo_OK(@PathVariable("id") Integer id) {
        return paymentHystrixService.paymentInfo_OK(id);
    }

    @GetMapping("/payment/hystrix/timeout/{id}")
    public String paymentInfo_TimeOut(@PathVariable("id") Integer id) {
        return paymentHystrixService.paymentInfo_TimeOut(id);
    }


    // ==========================服务熔断==========================
    @GetMapping("/payment/circuit/ok/{id}")
    public String paymentCircuitInfo_OK(@PathVariable("id") Integer id) {
        return paymentHystrixService.paymentCircuitInfo_OK(id);
    }

    @GetMapping("/payment/circuit/timeout/{id}")
    public String paymentCircuitInfo_TimeOut(@PathVariable("id") Integer id) {
        return paymentHystrixService.paymentCircuitInfo_TimeOut(id);
    }
}
